#include<bits/stdc++.h>
using namespace std;
const int maxl=1e5+5;
const double zer=1e-8;
struct node{
    double d,v,a,l,r;
}arr[maxl];
struct kk{
    int ld,rd;
}fi[maxl];
int T,n,m,ans1,ans2,sum[maxl];
double L,V,p[maxl];
bool cc(int x){
    int ld=1,rd=m,aim,res=L+100;
    if(arr[x].l-int(arr[x].l)<zer)aim=arr[x].l;
    else aim=arr[x].l+1;
    while(ld<=rd){
        int mid=ld+rd>>1;
        if(int(p[mid])>=aim){
            res=int(p[mid]);
            rd=mid-1;
        }
        else ld=mid+1;
    }
    //cout<<res<<" ";
    if(res<=int(arr[x].r))return true;
    else return false;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--){
        ans1=ans2=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=L+1;i++)sum[i]=0;
        for(int i=1;i<=n;i++)cin>>arr[i].d>>arr[i].v>>arr[i].a;
        for(int i=1;i<=m;i++)cin>>p[i];
        for(int i=1;i<=n;i++){
            if(int(arr[i].v)>V){
                if(arr[i].a<0){
                    arr[i].l=arr[i].d;
                    arr[i].r=arr[i].d+(arr[i].v*arr[i].v-V*V)/(-2*arr[i].a);
                    if(arr[i].r>L)arr[i].r=L;
                }
                else{
                    arr[i].l=arr[i].d;
                    arr[i].r=L;
                }
            }
            else{
                if(arr[i].a>0){
                    arr[i].l=arr[i].d+(V*V-arr[i].v*arr[i].v)/(2*arr[i].a);
                    if(arr[i].l>L)arr[i].l=0;
                    else arr[i].r=L;
                }
                else{
                    arr[i].l=L+1;
                    arr[i].r=L+1;
                }
            }
            int ll=arr[i].l+1,rr=arr[i].r+1;
            if(arr[i].l-ll<zer)ll=ll-1;
            sum[ll]++;
            sum[rr]--;
            if(cc(i))ans1++;
        }
        //while()
        cout<<ans1<<" "<<m-ans1<<'\n';

        //for(int i=1;i<=m;i++)cout<<sum[int(p[i])]<<" ";

    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15
*/
